/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package aviso.property.helpers;

import aviso.property.entity.ItemCategory;
import aviso.property.entity.Property;
import aviso.property.entity.PropertyGroup;
import java.io.Serializable;

/**
 *
 * @author avgusti
 */
public abstract class PropertyValueCountBase implements Serializable, Comparable<PropertyValueCountBase> {

    Long count;
    Property property;
    long[] valueIDs = null;

    public ItemCategory getCategory() {
        return property.getCategory();
    }

    public PropertyGroup getGroup() {
        return property.getGroup();
    }

    public Long getCount() {
        return count;
    }

    public Property getProperty() {
        return property;
    }

    public long[] getValueIDs() {
        return valueIDs;
    }

    public boolean hasIds() {
        return valueIDs.length > 0;
    }

    public boolean isLoaded() {
        return property != null && valueIDs != null;
    }

    public void setCount(Long count) {
        this.count = count;
    }

    public void setProperty(Property property) {
        this.property = property;
    }

    public void setValueIDs(long[] valueIDs) {
        this.valueIDs = valueIDs;
        this.count = (long) valueIDs.length;
    }

    public abstract String getValueForCompare();

    @Override
    public int compareTo(PropertyValueCountBase t) {
        if (property.getId() == t.property.getId()) {
            return getValueForCompare().compareToIgnoreCase(t.getValueForCompare());
        }
        return (int) (property.getId() - t.property.getId());
    }
}
